from apitest.lib.login import AccountClient, FweClient

from apitest.engine.const.model import Auth


# TODO 登录方法需自行实现
def get_token(phone: str = None):
    """
    根据用户中台账号池open api获取session注入auth信息中
    :param phone:
    :type phone: int or None
    :return:
    """
    token = "11111"
    app_id = ""
    ac = AccountClient(token=token, app_id=app_id)
    session = ac.get_session(phone)
    fc = FweClient(session=session)
    app_key = ""
    fw_service = fc.get_fwe_session(app_id, app_key)

    auth = Auth(cookie=dict(sessionid=session, fw_account_session_key=fw_service))
    return auth
